package it.ipermemory.graphic;

import it.ipermemory.R;
import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Display a pop-up showing the score of the game
 * 
 * @author Stefano Tonello (stefano.tonello8821@gmail.com)
 * @version 1.0
 * 
 */
public class ScorePopup extends CustomPopup {

	/**
	 * Text of pop-up
	 */
	private TextView textMessage;

	/**
	 * Button "OK" of pop-up
	 */
	private Button okButton;

	/**
	 * Possible button "No" of pop-up
	 */
	private Button noButton;

	/**
	 * Object for the preparation of a custom font
	 */
	private Typeface typface;

	/**
	 * Initialize a new pop-up
	 * 
	 * @param context
	 *            of application
	 * @param score
	 * 
	 */
	public ScorePopup(Context context, int score) {
		super(context, context.getResources().getString(R.string.end_game));

		// Customize the font of buttons and text
		typface = Typeface.createFromAsset(context.getAssets(),
				"fonts/wayoshi.ttf");

		textMessage = (TextView) findViewById(R.id.TextMessage);
		textMessage.setText(context.getResources().getString(R.string.end_game)
				+ "\n" + context.getResources().getString(R.string.score_game)
				+ " " + Integer.valueOf(score).toString() + " !");
		textMessage.setTypeface(typface);

		okButton = (Button) findViewById(R.id.OkButton);
		okButton.setTypeface(typface);
		okButton.setOnClickListener(this);

		noButton = (Button) findViewById(R.id.NoButton);
		noButton.setVisibility(View.GONE);
	}

	/**
	 * Action to be performed at the click of a button
	 * 
	 * @param v
	 *            button is pressed
	 */
	public void onClick(View v) {

		dismiss();

	}

}